import fieldLoader from "@/lib/field/core/fieldLoader"
import FIELD_VALUE_TYPE from "@/lib/field/constants/commonConstants"
import JsonSeriType from "@/lib/field/base/JsonSeriType"
import BaseFieldClass from "@/lib/field/fieldClass/BaseFieldClass"

export default class FlowLine extends BaseFieldClass{
	
	#from ;
	#to ;
	#flowLineLabelCode="_b_fl_label";
	constructor(from, to){
		super();
		this.#from = from;
		this.#to = to;
		
		let fgroups = [];
		let fg = fieldLoader.createFieldGroup("连线属性");
		fg.addField(fieldLoader.createField(FIELD_VALUE_TYPE.show.TEXT.code,"label",this.#flowLineLabelCode, ""));
		fg.addField(fieldLoader.createField(FIELD_VALUE_TYPE.show.TEXT.code,"连线属性","content", "连线测试默认值"));
		fgroups.push(fg);
		super.init({
			fieldGroups:fgroups
		});
		super.seriType = new JsonSeriType("FlowLine","flow");
	}
	
	genSeriObj(){
		
		let ret={
			"from":this.#from,
			"to":this.#to,
			"superSeriObj":super.genSeriObj(),
		};
		return ret;

	}
	
	seriObj(obj){
		this.#from =  obj.from;
		this.#to = obj.to;
		super.seriObj(obj.superSeriObj);
	}
	
	genProdObj(){
		let ret ={
			"from":this.#from,
			"to":this.#to
		}
		let allFields = super.getAllFields(); 
		for(let f of allFields){
			ret[f.code] = f.value || f.defaultValue;
		}
		return ret;
	}
	
	get from(){
		return this.#from;
	}
	
	set from(v){
		this.#from = v ;
	}
	
	get to(){
		return this.#to;
	}
	
	set to(v){
		this.#to = v ;
	}
	
	get label(){
		return super.getFieldValue(this.#flowLineLabelCode);
	}
	
	set label(v){
		super.setFieldValue(this.#flowLineLabelCode, v);
	}
	
}